package com.cskaoyan.service;

import com.cskaoyan.bean.Footprint;
import com.cskaoyan.bean.FootprintExample;
import com.cskaoyan.bean.FootprintVo;
import com.cskaoyan.mapper.FootprintMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class FootprintServiceImpl implements FootprintService {
    @Autowired
    FootprintMapper footprintMapper;
    @Override
    public Map selectList(Integer page, Integer size, Integer userId) {
        PageHelper.startPage(page,size);
        List<FootprintVo> footprintVos = footprintMapper.selectGoodsFootprint(userId);
        PageInfo<FootprintVo> pageInfo = new PageInfo<>(footprintVos);
        Map<String, Object> map = new HashMap<>();
        map.put("totalPages",pageInfo.getPages());
        map.put("footprintList",footprintVos);
        return map;
    }

    @Override
    public void deleteFootprint(Integer id) {
        Footprint footprint = new Footprint();
        footprint.setId(id);
        footprint.setDeleted(true);
        footprintMapper.updateByPrimaryKeySelective(footprint);
    }
}
